<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
 <%@ page language="java" import="com.kook.ball.util.GenerateRandomString" %>
<%@ page language="java" import="java.util.*" %>
<%@ page language="java" import="com.kook.ball.util.SendMail" %>
<%@ page language="java" import="com.kook.ball.util.SendSms" %>
<%@ page language="java" import="java.io.*" %>
<%@ page language="java" import="java.io.InputStream" %>
<%@ page language="java" import="java.io.FileInputStream" %>
<%@ page language="java" import="java.io.BufferedReader" %>
<%@ page language="java" import="java.net.HttpURLConnection" %>
<%@ page language="java" import="java.net.URL" %>
<%@ page language="java" import="java.text.*;" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/jquery-ui.css" />
<script src="js/jquery-1.9.0.js"></script>
<script src="js/jquery-ui.js"></script>

<style type="text/css">
.top { s
		text-align:right;		
	 }
</style>
<title>OTP PASSWORD</title>
</head>
<body>
<c:import url="header.jsp"></c:import>
	<%
String Flag = request.getParameter("Flag");
Properties props = new Properties();
 //String fileName = "pros.properties";
 //InputStream is = new FileInputStream(fileName);
 //props.load(is);
props.load(SendMail.class.getClassLoader().getResourceAsStream("pros.properties"));
String timeout=props.getProperty("timeout");
%>

<c:if test="${param.Flag == 'N'}">
<div  align="center">
<form method="post" action="CheckVerify.jsp">
<%
String username =(String)session.getAttribute("username");
String email =(String)session.getAttribute("email");
String telephone =(String)session.getAttribute("telephone");
//String VerifyCode =(String)session.getAttribute("VerifyCode");
//String ReferenceCode =(String)session.getAttribute("ReferenceCode");
GenerateRandomString verify=new GenerateRandomString();
String ReferenceCode1=verify.getAlphaNumeric(4);
String VerifyCode1=verify.getAlphaNumeric(4);
String ReferenceCode=request.getParameter("ReferenceCode1"); 
session.setAttribute("ReferenceCode",ReferenceCode1); 

String VerifyCode=request.getParameter("VerifyCode1"); 
session.setAttribute("VerifyCode",VerifyCode1); 

String text="Referencecode << "+ReferenceCode1+">> ,OTPCode <<"+VerifyCode1+">>";
String subject="Password OTP";

String checksendmail=props.getProperty("sendmail");
String checksendSms=props.getProperty("sendSms");

String Url=props.getProperty("urldefaultgateway");
String Password="";
	if(checksendSms.equals("Yes"))
	{
     SendSms sms=new SendSms(Url,Password);
     sms.SetProvider(telephone,text);
     
    }
	
	if(checksendmail.equals("Yes"))
	{
	 SendMail mail=new SendMail();
	 mail.Sending(email, subject, text);
	 //out.print("complete");
	}



//DateFormat dt=new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
//Date today=Calendar.getInstance().getTime();
//String StartDate=dt.format(today);

Date startdate=new Date();
session.setAttribute("Startdate",startdate); 
//out.print(startdate.getTime());

 %>	
<c:set var="count" value="0" scope="session" />
<h1>ReferenceCode: <% out.print(ReferenceCode1); %></h1><br>
<input type="password" name="passcode"><br>
<input type="submit" name="submit" value="add" ><br>
<div style="color:red">The OTP View Expire  in <%=timeout %> minutes
</div>
</form>
</c:if>

<c:if test="${param.Flag=='Y'}">
<div  align="center">
<form method="post" action="CheckVerify.jsp">
<%
String VerifyCode=(String) session.getAttribute("VerifyCode"); 
String ReferenceCode=(String) session.getAttribute("ReferenceCode"); 
//String StartDate_new = request.getParameter("StartDate");
String username =(String)session.getAttribute("username");
 %>
<br>
<h1>ReferenceCode:<%=ReferenceCode%></h1><br>
<input type="password" name="passcode"><br>
<input type="submit" name="submit" value="add" ><br>
<div style="color:red">The OTP View Expire  in <%=timeout %>  minutes
</div>
</form>
</div>
</c:if>




</body>
</html>